package gbench.appdemo.ggplot.junit;

import org.junit.jupiter.api.Test;

import gbench.common.fs.FileSystem;
import gbench.common.matlib.MatlibCanvas.NVec;
import gbench.common.matlib.data.DataReader;
import gbench.common.matlib.img.ImageOps;
import gbench.appdemo.ggplot.function.*;
import gbench.appdemo.ggplot.plot.panel.PanelFrame.PlotMode;

import static gbench.appdemo.ggplot.layer.geom.GeomPoint.geom_point;
import static gbench.appdemo.ggplot.plot.GGplot.ggplot;
import static gbench.appdemo.ggplot.aes.Aesthetics.*;
import static gbench.common.matlib.MatlibCanvas.*;
import static java.lang.Math.*;

public class JunitGeomPoint {
    
    @Test
    public void foo() throws InterruptedException {
        final var datafile = FileSystem.path("data.txt", this.getClass());
        final var df = DataReader.loaddfs(datafile).get("table3");
        final var length = 800;
        final var af = NVec.of(50,50,length/2,length/2);
        final var bimg = ggplot()
            .add(geom_point(aes("x", Range.P2(-3*PI, 3*PI, 50), "y", (Fx) x -> sin(x),"color", "ff0000","size",0.2d)))
            .addPanel(length, length, af) // 第一绘图面板
            .add(geom_point(aes("x", Range.P2(-3*PI, 3*PI, 50), "y", (Fx) x -> sin(x),"color", "ffffff","linedensity",100)))
            .addPanel(length, length, af) // 第二绘图面板
            .add(geom_point(aes("x",df.get("x(身高)") , "y",df.get("y(体重)"),"color", "ffff00","size",0.5d)))
            .addPanel(length, length) // 第三绘图面板
            .add(geom_point(aes("x",df.get("x(身高)") , "y",df.get("y(体重)"),"color", "00ffff","size",0.5d,"linedensity",5,"border",0.1)))
            .addPanel(length, length) // 第四绘图面板
            
            .print(PlotMode.GRID); // 绘图图片
        
        ImageOps.jpgwrite(bimg, "C:/Users/gbench/Desktop/tmp/geompoint.jpg");
        System.out.println(df);
        
        //System.out.println(Range.P2(47, 44, 11).dblL());
        Thread.sleep(100000);
    }

}
